#include "ModbusCmd.h"


#define  SlaveName "1"

ModbusCmd::ModbusCmd(QObject *parent)
{
}

ModbusCmd::~ModbusCmd()
{

}

void ModbusCmd::PhotographDone(int num,bool isOk)
{
	_ModbusHeader header;
	header.CommandId = 1;
	header.Param0 = num;
	while (-1!= master->ReadHoldingRegisters16(TakePhotoResultAddr,1).at(0))
	{
		mSleep(10);
	}
	QString data = QString("%1").arg((int)isOk);
	master->WriteHoldingRegisters16(TakePhotoResultAddr, data);
	SendData(header, SlaveName);
}

void ModbusCmd::ProcessImageResult(int num, int iResult)
{
	_ModbusHeader header;
	header.CommandId = 2;
	header.Param0 = num;
	while (-1 != master->ReadHoldingRegisters16(ProcessImageResultAddr, 1).at(0))
	{
		mSleep(10);
	}
	QString data = QString("%1").arg(iResult);
	master->WriteHoldingRegisters16(ProcessImageResultAddr,data);
	SendData(header, SlaveName);
}

void ModbusCmd::ReWarning(_ModbusHeader data)
{
	data.MsgType = 1;
	SendData(data, SlaveName);
}

void ModbusCmd::ReEquipmentState(_ModbusHeader data)
{
	data.MsgType = 1;
	SendData(data, SlaveName);
}

